<?php
/**
 * Login_model Class
 *
 */
class Login_model extends Model {
	/**
	 * Constructor
	 */
	function Login_model()
		{
			parent::Model();
		}
		
	// Inisialisasi nama tabel user
	var $table = 'user';
	
	/**
	 * Cek tabel user, apakah ada user dengan user_name, password dan cabang tertentu
	 */
	function check_user($user_name, $password, $id_cabang)
	{
		$query = $this->db->get_where($this->table, array('user_name' => $user_name, 'password' => $this->encrypt->SHA1($password), 'id_cabang' => $id_cabang), 1, 0);
		
		if ($query->num_rows() > 0)
		{
			return TRUE;
		}
		else
		{
			return FALSE;
		}
	}
	
	function get_logged_user($user_name)
	{
		$this->db->select('user.id_user, user.user_name, user.id_usergroup, usergroup.usergroup, user.id_cabang, cabang.cabang');
		$this->db->from($this->table);
		$this->db->join('cabang', 'cabang.id_cabang = user.id_cabang');
		$this->db->join('usergroup', 'usergroup.id_usergroup = user.id_usergroup');
		$this->db->where('user.user_name', $user_name);
		return $this->db->get()->result();
	}
}
// END Login_model Class

/* End of file login_model.php */ 
/* Location: ./system/application/model/login_model.php */